package sort;

import java.util.Arrays;

public class SelectSort implements BasicMethod{
    @Override
    public void sort(Comparable[] arr) {
        //外循环，截止到倒数第二个为止
        for (int i = 0; i <= arr.length-2; i++) {
            //每一轮假设最小内循环的首位
            int minIndex=i;
            //截止到数组最后
            for (int j = i+1; j <=arr.length-1 ; j++) {
                if (bigger(arr[minIndex],arr[j])){
                    minIndex=j;
                }
            }
            swap(arr,i,minIndex);
        }
    }

    public static class test{
        public static void main(String[] args) {
            Integer[] array={4,6,8,7,9,2,10,1};
            new BubbleSort().sort(array);
            System.out.println(Arrays.toString(array));
        }
    }
    
}
